home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / objc / objc-class.h < prev    next >
Text File  |  1992-03-02  |  4KB  |  155 lines

  1. /*
  2.  *    objc-class.h
  3.  *    Copyright 1988, NeXT, Inc.
  4.  */
  5.  
  6. #ifndef _OBJC_CLASS_H_
  7. #define _OBJC_CLASS_H_
  8.  
  9. #import <objc/objc.h>
  10. #import <objc/zone.h>
  11. /* 
  12.  *    Class Template
  13.  */
  14. struct objc_class {            
  15.     struct objc_class *isa;    
  16.     struct objc_class *super_class;    
  17.     const char *name;        
  18.     long version;
  19.     long info;
  20.     long instance_size;
  21.     struct objc_ivar_list *ivars;
  22.     struct objc_method_list *methods;
  23.     struct objc_cache *cache;
  24.      struct objc_protocol_list *protocols;
  25. };
  26. #define CLS_GETINFO(cls,infomask)    ((cls)->info & infomask)
  27. #define CLS_SETINFO(cls,infomask)    ((cls)->info |= infomask)
  28.  
  29. #define CLS_CLASS        0x1L
  30. #define CLS_META        0x2L
  31. #define CLS_INITIALIZED        0x4L
  32. #define CLS_POSING        0x8L
  33. #define CLS_MAPPED        0x10L
  34. #define CLS_FLUSH_CACHE        0x20L
  35. /* 
  36.  *    Category Template
  37.  */
  38. typedef struct objc_category *Category;
  39.  
  40. struct objc_category {
  41.     char *category_name;
  42.     char *class_name;
  43.     struct objc_method_list *instance_methods;
  44.     struct objc_method_list *class_methods;
  45.      struct objc_protocol_list *protocols;
  46. };
  47. /* 
  48.  *    Instance Variable Template
  49.  */
  50. typedef struct objc_ivar *Ivar;
  51.  
  52. struct objc_ivar_list {
  53.     int ivar_count;
  54.     struct objc_ivar {
  55.         char *ivar_name;
  56.         char *ivar_type;
  57.         int ivar_offset;
  58.     } ivar_list[1];            /* variable length structure */
  59. };
  60. /* 
  61.  *    Method Template
  62.  */
  63. typedef struct objc_method *Method;
  64.  
  65. struct objc_method_list {
  66.     struct objc_method_list *method_next;
  67.     int method_count;
  68.     struct objc_method {
  69.         SEL method_name;
  70.         char *method_types;
  71.                 IMP method_imp;
  72.     } method_list[1];        /* variable length structure */
  73. };
  74.  
  75. /* Protocol support */
  76.  
  77. @class Protocol;
  78.  
  79. struct objc_protocol_list {
  80.     struct objc_protocol_list *next;
  81.     int count;
  82.     Protocol *list[1];
  83. };
  84.  
  85. /* Definitions of filer types */
  86.  
  87. #define _C_ID        '@'
  88. #define _C_CLASS    '#'
  89. #define _C_SEL        ':'
  90. #define _C_CHR        'c'
  91. #define _C_UCHR        'C'
  92. #define _C_SHT        's'
  93. #define _C_USHT        'S'
  94. #define _C_INT        'i'
  95. #define _C_UINT        'I'
  96. #define _C_LNG        'l'
  97. #define _C_ULNG        'L'
  98. #define _C_FLT        'f'
  99. #define _C_DBL        'd'
  100. #define _C_BFLD        'b'
  101. #define _C_VOID        'v'
  102. #define _C_UNDEF    '?'
  103. #define _C_PTR        '^'
  104. #define _C_CHARPTR    '*'
  105. #define _C_ARY_B    '['
  106. #define _C_ARY_E    ']'
  107. #define _C_UNION_B    '('
  108. #define _C_UNION_E    ')'
  109. #define _C_STRUCT_B    '{'
  110. #define _C_STRUCT_E    '}'
  111.  
  112. /* Structure for method cache - allocated/sized at runtime */
  113.  
  114. typedef struct objc_cache *Cache;
  115.  
  116. struct objc_cache {
  117.     unsigned int mask;            /* total = mask + 1 */
  118.     unsigned int occupied;        
  119.     Method buckets[1];
  120. };
  121.  
  122. /* operations */
  123.  
  124. extern id class_createInstance(Class, unsigned idxIvars);
  125. extern id class_createInstanceFromZone(Class, unsigned idxIvars, NXZone *zone);
  126.  
  127. extern void class_setVersion(Class, int);
  128. extern int class_getVersion(Class);
  129.  
  130. extern Ivar class_getInstanceVariable(Class, const char *);
  131. extern Method class_getInstanceMethod(Class, SEL);
  132. extern Method class_getClassMethod(Class, SEL);
  133.  
  134. extern void class_addMethods(Class, struct objc_method_list *);
  135. extern void class_removeMethods(Class, struct objc_method_list *);
  136.  
  137. extern Class class_poseAs(Class imposter, Class original);
  138.  
  139. extern unsigned method_getNumberOfArguments(Method);
  140. extern unsigned method_getSizeOfArguments(Method);
  141. extern unsigned method_getArgumentInfo(Method m, int arg, const char **type, int *offset);
  142.  
  143. typedef void *marg_list;
  144.  
  145. #define marg_getRef(margs, offset, type) \
  146.     ( (type *)((char *)margs + offset) )
  147.  
  148. #define marg_getValue(margs, offset, type) \
  149.     ( *marg_getRef(margs, offset, type) )
  150.  
  151. #define marg_setValue(margs, offset, type, value) \
  152.     ( marg_getValue(margs, offset, type) = (value) )
  153.  
  154. #endif /* _OBJC_CLASS_H_ */
  155.